package com.gzyz.cheetah.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gzyz.cheetah.entity.dto.CommentDTO;
import com.gzyz.cheetah.entity.dto.PageDTO;
import com.gzyz.cheetah.entity.table.Comment;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 评论表 Mapper 接口
 * </p>
 *
 * @author xclhove
 * @since 2023-11-06
 */
@Mapper
public interface CommentMapper extends BaseMapper<Comment> {
    @Select("select c.id as id, content, document_id, user_id, c.create_time as create_time, " +
            "c.update_time as update_time, username " +
            "from comment as c, user as u " +
            "where c.user_id = u.id " +
            "and document_id = #{documentId} " +
            "limit #{start}, #{pageSize} ")
    public List<CommentDTO> pageDocumentComments(@Param("documentId") Integer documentId,
                                     @Param("start") Integer start,
                                     @Param("pageSize") Integer pageSize);
}
